//
// Created by wangheng on 2020/5/9.
//

#ifndef CPP_PRIMER_LIMIT_QUOTE_H
#define CPP_PRIMER_LIMIT_QUOTE_H

#include "Disc_quote.h"

class Limit_quote : public Disc_quote {
    Limit_quote() = default;
    Limit_quote(const std::string& book, double p, std::size_t qty, double disc) :
        Disc_quote(book, p, qty, disc) {}

    double net_price(std::size_t n) const override ;
};

double Limit_quote::net_price(std::size_t n) const {
    if (n <= quantity)
        return n * (1 - discount) * price;
    else
        return quantity * (1 - discount) * price + (n - quantity) * price;
}

#endif //CPP_PRIMER_LIMIT_QUOTE_H
